import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
// TODO 记得修改时间否则会无法使用
export const LowCode = "2026/3/25"

const store = new Vuex.Store({
	state: {
		 // baseUrl: 'https://td.lszbg.com', //线上正式域名https://h5.hwhsh.com https://td.lszbg.com
		  baseUrl: ' https://td.test.lszbg.cn', //测试域名 https://shengtan.hwhsh.com
		withdrawalTarget: 10, //提现目标
	},
	mutations: {
		// 设置提现目标值
		setWithdrawalTarget(state, value) {
			state.withdrawalTarget = value
		}
	},
	getters: {
		// 获取提现目标值
		getWithdrawalTarget: state => {
			return state.withdrawalTarget
		}
	}
})
export default store //导出store对象

export function getDaysBetweenStop(dateStr) {
	const currentDateYear = new Date().getFullYear()
	const currentDateMonth = new Date().getMonth() + 1
	const currentDateDay = new Date().getDate()
	const currentDate = new Date(
		currentDateYear + '/' + currentDateMonth + '/' + currentDateDay,
	).getTime() // 获取时间戳
	const date1Time = new Date(dateStr).getTime() // 获取时间戳
	const ONE_DAY = 1000 * 60 * 60 * 24 // 一天的毫秒数
	const difference = date1Time - currentDate // 获取时间差
	return Math.round(difference / ONE_DAY) // 两个日期之间的天数
}
// rpx转px
export function rpxToPx (rpx){
	const screenWidth = uni.getSystemInfoSync().screenWidth
	return (screenWidth * Number.parseInt(rpx)) / 750
}